var mRequest = require('../goodsDetailsService.js');
// var mDetails = require('../goodsDetails.js');

let app = getApp()
/**
 * 竞拍记录view
 */
Component({

  options: {
    // 在组件定义时的选项中启用多slot支持
    multipleSlots: true
  },

  /**
   * 组件的属性列表
   * 用于组件自定义设置
   */
  properties: {
    url: {
      type: String,
      value: '',
    },
  },

  data: {
    biddersPage: 0,
    goodsId: '',
    isSeeBiddersMore: true,    // 竞拍记录查看更多是否显示
    isBiddersListVisible: true,// 竞拍记录
    isSpeedVisible: true,      // 快速出花弹窗是否显示
    speedFolwerMsg: '是否快速出果冻',
    biddresData: {}   // 竞拍记录数据
  },

  methods: {
    /**
      * 获取竞拍记录接口
      */
    showBiddersData: function () {
      var that = this
      var param = {
        goodsId: this.data.goodsId,
        startPage: this.data.biddersPage
      }

      mRequest.getBiddersData(param,
        function (data) {
          console.log('竞拍记录接口  成功')
          if (that.data.biddersPage == 0) {
            if (data.items.length > 0) {
              that.setData({
                biddresData: data,
                isSeeBiddersMore: false,      // 竞拍查看更多显示
                isBiddersListVisible: false   // 竞拍记录样式显示
              })
            } else {
              that.setData({
                isSeeBiddersMore: true,
                isBiddersListVisible: true
              })
            }

          } else {
            if (data.items.length > 0) {
              let allData = that.data.biddresData.items.concat(data.items)
              that.data.biddresData.items = allData
              that.setData({
                biddresData: that.data.biddresData
              })
            } else {
              that.showTost('没有更多数据');
              that.setData({
                isSeeBiddersMore: true,
                biddersPage: that.data.biddersPage - 1
              })
            }
          }
        })
    },

    /**
     * 竞拍记录查看更多
     */
    biddresSeeMoreClick: function () {
      this.setData({
        userId: app.globalData.userId,
        biddersPage: this.data.biddersPage + 1
      })
      this.showBiddersData()
    },

    /**
    * 竞拍快速出花 +5 颗果冻 
    */
    addMoneyClick: function () {
      this.setData({
        isSpeedVisible: false
      })
    },

    /**
     * 快速出花取消回调
     */
    cancelCallBack: function () {
      this.setData({
        isSpeedVisible: true
      })
    },

    /**
     * 快速出花确定回调
     */
    confirmCallBack: function () {
      // 竞拍把input值改为商品值 + 5
      this.setData({
        inputValue: this.data.goodsDetailsData.goodsListEntity.integral + 5,
        isSpeedVisible: true
      })
      // mDetails.showCommitMonetData()
    },



  }
})
